package com.example.job.service;

import com.example.common.api.Service;
import com.example.job.po.SysJob;

import java.util.Date;

public interface SysJobService extends Service<SysJob> {

    /***
     *
     * 创建一个定时任务.
     * @param job
     * @throws Exception
     */
    public void addJob(SysJob job);

    /**
     * 获取任务状态
     *
     * @return
     * @throws Exception
     */
    public String getJobState(SysJob job) throws Exception;


    /**
     * 暂停任务
     *
     * @param job
     * @throws Exception
     */
    public void pauseJob(SysJob job) throws Exception;


    /**
     * 恢复任务
     *
     * @param job
     * @return
     * @throws Exception
     */
    public void resumeJob(SysJob job) throws Exception;


    /***
     *
     * 删除任务
     * @param job
     * @throws Exception
     */
    public void deleteJob(SysJob job) throws Exception;


    /***
     * 修改任务
     * @param job
     * @throws Exception
     */
    public void modifyJob(SysJob job) throws Exception;


    /***
     *
     * 计算最近一次执行时间
     * @param startTime
     * @param cron
     * @return
     * @throws Exception
     */
    public Date getNextTime(Date startTime, String cron) throws Exception;


    /**
     * 初始化定时任务
     *
     * @throws Exception
     */
    public void initJobService() throws Exception;


    /**
     * @param date
     * @return
     * @throws Exception
     */
    public String createCronExpression(Date date) throws Exception;
}
